package com.coincalf.wallet.service.impl;

import com.coincalf.wallet.entity.UserInfo;
import com.coincalf.wallet.feign.dto.UserInfoDTO;
import com.coincalf.wallet.mapper.UserInfoMapper;
import com.coincalf.wallet.service.UserInfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表(（此表是一个同步表，主要把主表user的一些常用信息同步过来）) 服务实现类
 * </p>
 *
 * @author crow
 * @since 2018-05-21
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

    /**
     * 添加用户信息
     *
     * @param userInfo
     * @return
     */
    @Override
    public boolean addUserInfo(UserInfoDTO userInfo) {
        int count = baseMapper.addUserInfo(userInfo);
        return count > 0;
    }

    /**
     * 更新用户信息
     *
     * @param userInfo
     * @return
     */
    @Override
    public boolean modifyUserInfo(UserInfoDTO userInfo) {
        int count = baseMapper.modifyUserInfo(userInfo);
        return count > 0;
    }

    @Override
    public UserInfo selectByPhone(String phone) {
        UserInfo userInfo = new UserInfo();
        userInfo.setMobile(phone);
        return baseMapper.selectOne(userInfo);
    }

}
